package com.hualude.roadsign.controller;

import com.hualude.roadsign.dto.DTRequestDto;
import com.hualude.roadsign.dto.DTResponseDto;
import com.hualude.roadsign.dto.JsonMsgDto;
import com.hualude.roadsign.service.SignalLampCheckService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by ding on 2017/8/4.
 */
@Controller
@RequestMapping("/rds_signalLampCheck")
public class SignalLampCheckController {

    @Resource
    private SignalLampCheckService signalLampCheckService;

    @RequestMapping(value = "/getSignalLampFaultCheck4DT")
    @ResponseBody
    public DTResponseDto getSignalLampFaultCheck4DT(DTRequestDto dtRequestDto, Integer actorId , Integer orgId) {
        DTResponseDto dtResponseDto = new DTResponseDto();
        try {
            dtResponseDto = signalLampCheckService.getSignalLampFaultCheck4DT(dtRequestDto,actorId, orgId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dtResponseDto;
    }

    @RequestMapping(value = "/lampFaultAudit")
    @ResponseBody
    public JsonMsgDto lampFaultAudit(Integer isPass, String feedback, Integer lampFaultId, Integer userId) throws Exception {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(signalLampCheckService.lampFaultAudit(isPass, feedback, lampFaultId, userId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }

    @RequestMapping(value = "/getLampFaultCheckList4App")
    @ResponseBody
    public JsonMsgDto getLampFaultCheckList4App(Integer orgId, String actorIds, Integer faultStatus, Integer count, Integer size) throws Exception {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(signalLampCheckService.getLampFaultCheckList4App(orgId, actorIds, faultStatus, count, size));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }

    @RequestMapping(value = "/getSignalLampInfo2Fault")
    @ResponseBody
    public JsonMsgDto getSignalLampInfo2Fault(Integer signalLampId) throws Exception {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(signalLampCheckService.getSignalLampInfo2Fault(signalLampId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }

    @RequestMapping(value = "/getSignalLampFaultInfo2Fault")
    @ResponseBody
    public JsonMsgDto getSignalLampFaultInfo2Fault(Integer signalLampId, Integer lampFaultId) throws Exception {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(signalLampCheckService.getSignalLampFaultInfo2Fault(signalLampId, lampFaultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }
}
